import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
 import vueDevTools from 'vite-plugin-vue-devtools'
export default defineConfig({
  plugins: [vue(),vueDevTools()],
  define: {
    // 添加全局环境变量支持
    'import.meta.env': JSON.stringify(import.meta.env)
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src')
    }
  },
  server: {
    open: true,   // 自动打开浏览器
    proxy: {
      '/api': {
        target: 'http://localhost:8081',
        secure: false,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      }
    }
  }
})
